package com.xinan.weixin.media;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StringKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

@TableBind(tableName = "wx_media")
public class WxMedia extends Model<WxMedia>{
    public static final WxMedia dao = new WxMedia();

    //columns START
    private String ID = "id";  //

    public void setId(int value) {
        set(ID, value);
    }

	public int getId() {
		return get(ID);
	}
	//columns END

    public List<WxMedia> findAll() {
        return find("select * from wx_media");
    }
    /**
     * @param   where
     * @return  Record
     */
    public List<Record> findAlls(String where) {
        String sqlExp = " from wx_media";
        if(StringKit.notBlank(where)){
                sqlExp += " where " + where;
        }
                return Db.find( "select * " +sqlExp );

    }

    public Page<WxMedia> page(int pageNumber, int pageSize, String where) {
        String sqlExp = "from wx_media";
        if(StringKit.notBlank(where)){
            sqlExp += " where " + where;
        }
        return paginate(pageNumber, pageSize, "select *", sqlExp);
    }
}

